﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TPCS03
{
    static class Loop
    {
        public static int Fibo(int rank)
        {
            int f = 0;
            int f1 = 1;
            int f2 = 1;
            int i;

            if (rank <= 0)
                f = 0;
            else if (rank == 1)
                f = 1;
            else
                for (i = 2; i < rank; i++)
                {
                    f = f1 + f2;
                    f1 = f2;
                    f2 = f;
                }

            return f;
        }

        public static int subSumVect(int[] vect, int jump)
        {
            int somme = 0;
            for (int i = 0; i < vect.Length; i += jump)
            {
                somme += vect[i];
            }
            return (somme);
        }

        public static void printBack(int[] vect)
        {
            string mirror = "[";

            for (int i = vect.Length; i > 0; i--)
            {
                if (i != 1)
                    mirror += Convert.ToString(vect[i - 1]) + ",";
                else
                    mirror += Convert.ToString(vect[i - 1]);
            }

            Console.WriteLine(mirror + "]");
        }

        public static void findNumber(int val)
        {
            do
                Console.WriteLine();
            while (Console.ReadLine() != Convert.ToString(val));
        }

        public static void matPrint(int[][] matA)
        {
            string outputText = "[ ";
            string array;
            for (int i = 0; i < matA.Length; i++)
            {
                array = "[";
                for (int j = 0; j < matA.Length; j++)
                {
                    if (j != (matA[i].Length - 1))
                        array += matA[i][j] + ", ";
                    else
                        array += matA[i][j] + "]";
                }
                if (i != (matA.Length - 1))
                    outputText += array + "," + "\n";
                else
                    outputText += array + " ]";
            }
            Console.WriteLine(outputText);
        }
    }
}
